package com.sh.data.engine.application.model.mapper.integration;

import com.sh.data.engine.application.model.request.integration.TaskConfigRequest;
import com.sh.data.engine.domain.integration.api.taskconfig.model.domain.TaskConfigDomain;
import com.sh.data.engine.domain.integration.api.taskconfig.model.param.TaskConfigParam;
import com.sh.data.engine.domain.util.ConvertUtil;

public class ApiTaskConfigConvert {

    public static TaskConfigParam convertTaskConfigParam(TaskConfigRequest taskConfigRequest) {
        TaskConfigParam taskConfigParam =
            ConvertUtil.copyProperties(taskConfigRequest, TaskConfigParam.class);

        taskConfigParam.setTargetFields(
            ConvertUtil.copyProperties(
                taskConfigRequest.getTargetFields(), TaskConfigParam.TargetField.class));
        taskConfigParam.setFieldMappings(
            ConvertUtil.copyProperties(
                taskConfigRequest.getFieldMappings(), TaskConfigParam.FieldMapping.class));
        taskConfigParam.setPartitions(
            ConvertUtil.copyProperties(
                taskConfigRequest.getPartitions(), TaskConfigParam.PartitionField.class));
        return taskConfigParam;
    }

    public static TaskConfigDomain convertTaskConfigDomain(TaskConfigRequest taskConfigRequest) {
        TaskConfigDomain taskConfigDomain =
            ConvertUtil.copyProperties(taskConfigRequest, TaskConfigDomain.class);

        taskConfigDomain.setTargetFields(
            ConvertUtil.copyProperties(
                taskConfigRequest.getTargetFields(), TaskConfigDomain.TargetField.class));
        taskConfigDomain.setFieldMappings(
            ConvertUtil.copyProperties(
                taskConfigRequest.getFieldMappings(), TaskConfigDomain.FieldMapping.class));
        taskConfigDomain.setPartitions(
            ConvertUtil.copyProperties(
                taskConfigRequest.getPartitions(), TaskConfigDomain.PartitionField.class));
        return taskConfigDomain;
    }
}
